<template>
	<view class="container">
		<image mode="widthFix" class="logo" src="../../static/logo.png"></image>
		<uv-loading-icon size="36" iconColor="#ccc" status="loading" loadingText=""></uv-loading-icon>
	</view>
</template>

<script setup>
	import {
		ref,
		reactive,
		toRefs,
		toRef,
		getCurrentInstance,
		onMounted
	} from 'vue';
	import {
		onShow,
		onLoad
	} from '@dcloudio/uni-app';
	const {
		proxy: that
	} = getCurrentInstance();
	const data = reactive({
		hrefData: ''
	});
	let {
		hrefData
	} = toRefs(data);
	onLoad((e) => {
		console.log('页面显示执行block', e);
		if (e.type) {
			data.hrefData = e;
		}
		wxGetOpenId();
	});
	// 获取openid 用户信息
	const wxGetOpenId = (code) => {
		uni.login({
			timeout: 5000,
			success(login) {
				that.$Api
					.wxGetOpenId({
						code: login.code,
						openid: ''
					})
					.then((res) => {
						console.log(res, 'openid');
						if (res.code == 200) {
							uni.setStorageSync('userInfo', res.data);
							// 公众号消息判断
							if (data.hrefData) {
								console.log("公众号进来", data.hrefData)
								switch (Number(data.hrefData.type)) {
									case 1:
										if (res.data.position_id == 12 || res.data.position_id == 11) {
											// 项目详情
											uni.reLaunch({
												url: '/pagesA/project_detail_kh/project_detail_kh?id=' +
													data.hrefData
													.object_id
											});
										} else {
											// 项目详情
											uni.reLaunch({
												url: '/pagesA/project_schedule/project_schedule?id=' +
													data.hrefData
													.object_id
											});
										}
										break;
									case 2:
										// 增减项详情
										uni.reLaunch({
											url: '/pages/increase_decrease_items/idi_info/idi_info?id=' +
												data.hrefData.object_id
										});
										break;
									case 3:
										// 售后详情
										uni.reLaunch({
											url: '/pages/after_sales_list/as_info/as_info?id=' +
												data.hrefData
												.object_id
										});
										break;
								}
								return;
							}
							uni.reLaunch({
								url: '/pages/index/index'
							});
						}
					})
					.catch((err) => {
						console.log(err);
					});
			},
			fail(err) {
				console.log(err);
			}
		});
		return;
	};
</script>

<style lang="scss" scoped>
	.container {
		width: 100%;
		height: 100vh;
		display: flex;
		align-items: center;
		justify-content: center;
		flex-direction: column;

		.logo {
			width: 200rpx;
			margin-top: -200rpx;
			margin-bottom: 30rpx;
		}
	}
</style>